package com.gxg.config.redis;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * 类名：RedisCacheConfiguration<br>
 * 描述：<br>
 * 创建人：<guxiaoguang>
 * 创建时间：2018/05/07 17:33<br>
 *
 * @version v1.0
 */
@Configuration
@ConfigurationProperties(prefix = "redis")
public class RedisCacheConfiguration extends CachingConfigurerSupport {
    private String host;
    private int port;
    private String password;
    private int timeout;

    @Bean
    public JedisPool redisPoolFactory() {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
/*        jedisPoolConfig.setMaxIdle(maxIdle);*/
        /*jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);*/

        JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password);

        return jedisPool;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getTimeout() {
        return timeout;
    }

    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

}